<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>请命名~</title>
	</head>
	<body>
		<button>click1</button>
		<button>click2</button>
		<button>click3</button>
		<script>
			function fun1() {
			    var a = 2;
			    var b = "abc";
			
			    function setA(x) {
			        a = x;
			        console.log(a);
			    }
			    function getA() {
			        console.log(a);
			        return a;
			    }
			    // test
			    function test() {
			        console.log(a);
			        return a;
			    }
			    return {
			        setA:setA,
			        getA:getA
			    };
			}
			var f = fun1();  // 在上面的函数中，有两个闭包（setA，getA），在函数fun1执行完
			f.getA()
			f.setA(343)			
			f.getA()

			// function showDelay(msg, time){
			// 	setTimeout(function(){
			// 		console.log(msg);
			// 	}, time)
			// }
			// showDelay(23, 500)
		</script>
	</body>
</html>
